import request from '@/api/http.js'

// 获取订单详情数据列表 --OrderDetailInfo 价格
export const orderDetailSearchList = (id) => {
  return request.get('api/OrderDetailInfo/getPageData?id=' + id)
}

// 获取所有订单数据 --OrderInfo
export const orderSearchList = () => {
  return request.get('api/OrderInfo/getPageDate')
}

// 条件搜索 --OrderInfo
export const orderInfoSearch = (params) => {
  console.log('发送参数:', params)
  console.log('最终请求 URL:', 'api/OrderInfo/getPageDate', params);
  const query = new URLSearchParams(params).toString();
  return request.get(`api/OrderInfo/getPageDate?${query}`);
};

// 条件搜索 --Inventory
export const InventorySearch = (params) => {
  console.log('发送参数:', params)
  return request.post('api/Inventory/getPageData', params)
};

// 获取仓库数据
export const getWareHouse = () => {
  return request.post('api/Warehouse/getPageData', {
    page: 1,
    rows: 10000,
    sort: 'CreateDate',
    order: 'desc',
    wheres: JSON.stringify([])
  })
}

//获取存货数据
export const getInventory = (params) => {
  return request.post('api/Inventory/getPageData', params)
}

// return request.delete('/category/delete?id='+id) 
//获取部门信息
export const getDepemendents = () => {
  return request.post('api/Department/getPageData', {
    page: 1,
    rows: 10000,
    sort: 'CreateDate',
    order: 'desc',
    wheres: JSON.stringify([])
  })
}

// //获取仓库信息
export const getWareHouses = () =>{
  return request.post('api/Warehouse/getPageData')
}

//获取员工信息
export const getEmployees = () => {
  return request.post('api/Employees/getPageData', {
    page: 1,
    rows: 10000,
    sort: 'CreateDate',
    order: 'desc',
    wheres: JSON.stringify([])
  })
}

//添加出库单
export const AddMaterialOutboundOrder = (params) => {
  return request.post('api/Chanjet/AddMaterialOutboundOrder', params)
}


//获取出库单
export const MaterialOutboundOrderSearch = (params) => {
  const query = new URLSearchParams(params).toString();
  return request.get(`api/MaterialOutboundOrderInfo/getPageDate?${query}`)
}

// 获取现存量接口
export const getExistingQuantity = (params) => {
  const query = new URLSearchParams(params).toString();
  return request.get(`api/MaterialOutboundOrderInfo/getExistingQuantity?${query}`)
}

//审核材料出库单
export const ReviewMaterialOut = (id) => {
  return request.post(`api/Chanjet/ReviewMaterialOutboundOrder/${id}`)
}

//删除材料出库单
export const DeleteMaterialOut = (id) => {
  console.log('进入接口', id)
  return request.post(`api/Chanjet/DeleteMaterialOutboundOrder/${id}`)
}

//弃审材料出库单
export const UnReviewMaterialOrder = (id) => {
  console.log('进入接口', id)
  return request.post(`api/Chanjet/UnReviewMaterialOutboundOrder/${id}`)
}

// 获取材料出库编码
export const getMaterialOutboundOrderCode = () => {
  return request.get('api/MaterialOutboundOrderInfo/GetMaterialOutboundOrderCode')
}